package untils

import (
	"log"
	"shop/common/global"
	"time"
)

func SyncDataLock(key, value string, expire time.Duration) bool {
	result, _ := global.Rdb.SetNX(global.Ctx, key, value, expire).Result()
	if !result {
		return false
	}
	return result
}
func ReleaseDataLock(key string) {
	_, err := global.Rdb.Del(global.Ctx, key).Result()
	if err != nil {
		log.Printf("分布式锁释放失败：%v", err)
	}
}
